home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Mac Mania 1
/
MacMania 1.toast
/
Games
/
Mech Zone
/
Sample Robots
/
IterBot
< prev
next >
Wrap
Text File
|
1991-09-07
|
3KB
|
109 lines
` IterBot Series 1
` Copyright 1991 Calvin Hass
` Name: Iteration Robot One
` Mobility: Immobile
` Degree Accuracy: 1
` Processor Speed: 17
` Comments: Very effective against most stationary robots and
` corner hogs such as Kelly. It will track most
` moving robots as well.
` NB: Processor speed is measured by the maximum number of aim
` refinements that are necessary in order to locate the other
` robot. 17 is the fastest possible in Integer mathematics.
` *** Initialize Robot ***
Equip 6 0 0 0 1 125 `6 Lasers, Turbo Unit
SetShields 1 1 1 1 1 1 1 1 `All sides covered
TurboOn `Prepare for quick escape
LET Right = 1
LET Left = 0-1
LET Offset = 0
LET MaxLevel = 7
Dimension Arc(7)
LET Arc(1) = 360 `Here is the aiming algorithm
LET Arc(2) = 180 `in number of degrees arc for
LET Arc(3) = 90 `each aiming level. Level 1
LET Arc(4) = 30 `should always be 360 degrees
LET Arc(5) = 6
LET Arc(6) = 2
LET Arc(7) = 1
` *** Main Loop ***
100 If Fuel <=10 Then GOTO 5000 `If out of fuel, freeze
110 LET OldDamage = Damage `Update the old damage level
120 GOSUB 1000 `Seek & Destroy other robots
999 GOTO 100 `Continue main loop
` Seek & Destroy is a modular algorithm I designed to be very flexible
` and fast. It has been optimized to a certain extent, but still
` reasonably readable. One should be able to substitute any aiming
` algorithm in the Arc array above. The standard method uses
` refinement for aiming routines.
` *** Seek & Destroy ***
1000 LET Level = 2 `Start with level 2
1010 LET PrevLevel = Level - 1
LET Segments = Arc(PrevLevel) / Arc(Level)
FOR Scan = 1 To Segments
GOSUB 4000 `Check for damage
LET Temp = Arc(Level) + Offset `Add both turns together
LET Offset = 0
Swivel Temp
LET ScanAngle = Arc(Level) / 2
ObjectScan ScanAngle
If Range > 0 Then GOTO 1030
NEXT
1020 LET Level = Level - 1
LET BackTrack = 0 - Arc(Level)
Swivel BackTrack
GOTO 1010
1030 LET Level = Level + 1
If Level > MaxLevel Then GOTO 1040
LET HalfArc = Arc(Level) * 15
LET Temp = 0-HalfArc
LET Offset = Temp / 10
GOTO 1010
1040 Zap 3 `Zap three times
GOSUB 4000
Zap 3
GOSUB 4000
Zap 3
GOSUB 4000
ObjectScan 0
If Range > 0 Then GOTO 1040
GOTO 1020
4000 LET NewDamage = Damage - OldDamage `Check to see how much
If NewDamage > 100 Then GOSUB 6000 `new damage there is
RETURN
5000 SetShields 1 2 3 4 4 3 2 1 `Stagnant State - Out of Fuel
5010 GOTO 5010 `Shields up and stay
6000 LET OldDamage = Damage
6010 If YCoOrd > 10 Then GOTO 6100 `Quick Escape Up
6020 If XCoOrd >= 38 Then GOTO 6200 `Escape Left
6030 If XCoOrd < 38 Then GOTO 6300 `Escape Right
6100 EngineOn
Wait 4
EngineOff
RETURN
6200 Turn Left
Turn Left
EngineOn
Wait 4
EngineOff
Turn Right
Turn Right
RETURN
6300 Turn Right
Turn Right
EngineOn
Wait 4
EngineOff
Turn Left
Turn Left
RETURN